// pages/orderdeliver/orderdeliver.js
var app = getApp();
var com = require('../../common.js')
Page({
  data: {
    info: {},
    list: [],
    local: '请选择发货单号',
    localcode: '',
    loacalnumber: ''
  },
  onLoad: function(options) {
    var Б = this
    Б.setData({
      id: options.id
    })
    Б.onOrderCentent();
    Б.logistics()
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {},
  //获取订单详情
  onOrderCentent() {
    var Б = this,
      id = Б.data.id,
      url = app.link.orderCentent + id + '.st'
    com.link(url, {}, function(rep) {
      console.log(rep);
      Б.setData({
        info: rep.data.data
      })
    }, 'GET')
  },
  //获取物流编码
  logistics() {
    var Б = this,
      u = app.link.logistics
    com.link(u, {}, function(rep) {
      console.log(rep);
      Б.setData({
        list: rep.data.response.list
      })
    }, 'GET')
  },
  bindPickerChange(e) {
    var Б = this,
      list = Б.data.list
    Б.setData({
      local: list[e.detail.value].title,
      localcode: list[e.detail.value].code,
    })
    console.log(e)
  },
  loacalnumber(e) {
    var Б = this
    Б.setData({
      loacalnumber: e.detail.value
    })
  },
  clickFahuo() {
    var _this = this,
      id = _this.data.id,
      url = app.link.ЯЭЧюǘФЖ + id + '.st',
      data = {
        waybill: _this.data.loacalnumber,
        logistics: _this.data.localcode
      }
    com.link(url, data, function(rep) {
      console.log(rep)
      com.toast(rep.data.message)
      if (rep.data.state) {
        setTimeout(() => {
          wx.navigateBack({
            delta: 1
          })
        }, 1500)
      }
    }, "GET")
  }
})